cmake_minimum_required(VERSION 3.16)
project(VSyntaxHighlighting VERSION 1.0 LANGUAGES C CXX)

set(CMAKE_INCLUDE_CURRENT_DIR ON)

set(QT_DEFAULT_MAJOR_VERSION 6 CACHE STRING "Qt version to use (5 or 6), defaults to 6")
find_package(Qt${QT_DEFAULT_MAJOR_VERSION} REQUIRED COMPONENTS Core Gui Network)
find_package(Qt${QT_DEFAULT_MAJOR_VERSION} OPTIONAL_COMPONENTS Core5Compat)

if ((QT_DEFAULT_MAJOR_VERSION GREATER 5))
    qt_standard_project_setup()
else()
    set(CMAKE_AUTOMOC ON)
    set(CMAKE_AUTORCC ON)
    set(CMAKE_AUTOUIC ON)
endif()

add_library(VSyntaxHighlighting
    data/themes/theme-data.qrc
    autogenerated/ksyntaxhighlighting_version.h
    autogenerated/src/lib/ksyntaxhighlighting_logging.cpp autogenerated/src/lib/ksyntaxhighlighting_logging.h
    src/lib/abstracthighlighter.cpp src/lib/abstracthighlighter.h src/lib/abstracthighlighter_p.h
    src/lib/context.cpp src/lib/context_p.h
    src/lib/contextswitch.cpp src/lib/contextswitch_p.h
    src/lib/definition.cpp src/lib/definition.h src/lib/definition_p.h
    src/lib/definitiondownloader.cpp src/lib/definitiondownloader.h
    src/lib/definitionref_p.h
    src/lib/foldingregion.cpp src/lib/foldingregion.h
    src/lib/format.cpp src/lib/format.h src/lib/format_p.h
    src/lib/htmlhighlighter.cpp src/lib/htmlhighlighter.h
    src/lib/keywordlist.cpp src/lib/keywordlist_p.h
    src/lib/ksyntaxhighlighting_export.h
    src/lib/matchresult_p.h
    src/lib/repository.cpp src/lib/repository.h src/lib/repository_p.h
    src/lib/rule.cpp src/lib/rule_p.h
    src/lib/state.cpp src/lib/state.h src/lib/state_p.h
    src/lib/syntaxhighlighter.cpp src/lib/syntaxhighlighter.h
    src/lib/textstyledata_p.h
    src/lib/theme.cpp src/lib/theme.h
    src/lib/themedata.cpp src/lib/themedata_p.h
    src/lib/wildcardmatcher.cpp src/lib/wildcardmatcher_p.h
    src/lib/xml_p.h
)
target_include_directories(VSyntaxHighlighting PUBLIC
    autogenerated
    autogenerated/src/lib
)

target_compile_definitions(VSyntaxHighlighting PUBLIC
    KSYNTAXHIGHLIGHTING_LIBRARY
)

target_link_libraries(VSyntaxHighlighting PUBLIC
    Qt::Core
    Qt::Gui
    Qt::Network
)

if((QT_DEFAULT_MAJOR_VERSION GREATER 5))
    target_link_libraries(VSyntaxHighlighting PUBLIC
        Qt::Core5Compat
    )
endif()
